# -*- coding: UTF-8 -*-
# 2023/12/1 12:42
from PIL import Image
from PIL.ImageTk import PhotoImage as pil_PhotoImage
from ttkbootstrap import Toplevel, Label
from ttkbootstrap.scrolled import ScrolledFrame


class double_clicked_top(Toplevel):
    def __init__(self, image_path, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.image_path = image_path

        self.windows_init()
        self.setupUI()
        self.setlayout()

    def windows_init(self):
        self.grab_set()  # 设置为模态窗口
        self.minsize(486, 864)
        self.place_window_center()

    def setupUI(self):
        """
        根据提供的地址返回对应btn_pil_PhotoImage,并给加上image_path属性
        不对尺寸做出任何调整
        """
        self.scroll_show_frame = ScrolledFrame(self)

        self.label_img = Image.open(self.image_path)
        self.label_img.thumbnail((486, 864))

        self.label_pil_PhotoImage = pil_PhotoImage(self.label_img)

        self.double_clicked_label = Label(self.scroll_show_frame, image=self.label_pil_PhotoImage)

    def setlayout(self):
        self.scroll_show_frame.place(relx=0, rely=0, relwidth=1, relheight=1)
        self.double_clicked_label.pack(fill="both")
